from django.db import models

# Create your models here.
# from userapp.models import User


class Course(models.Model):
    #标题
    title = models.CharField(max_length=255)
    #简介
    desc = models.CharField(max_length=255)
    #作者
    author = models.CharField(max_length=255)
    #价格
    price = models.CharField(max_length=255)
    #是否上线
    is_online = models.IntegerField(default=0)
    #简介图
    pic = models.ImageField()
    #上线时间
    createtime = models.DateTimeField(auto_now_add=True)
    #关注
    flow = models.IntegerField()
    #阅读
    read = models.IntegerField()
    #课程类型   免费1会员2训练营3
    type = models.IntegerField()
    #课程标签
    tags_id = models.IntegerField(default=1)
    #课程用户多对多
    # user = models.ManyToManyField(to='User',through= 'UsertoCourse',through_fields=('course_id','uid'))

    class Meta:
        db_table = 'course'


class CoursetoStage(models.Model):
    #课程-阶段表
    course_id = models.IntegerField()
    stage_id = models.IntegerField()

    class Meta:
        db_table = 'course_to_stage'


class Path(models.Model):
    #路径
    path = models.CharField(max_length=255)
    #路径中课程数量
    course_num = models.IntegerField()
    #简介
    desc = models.CharField(max_length=255)
    #完成学习人数
    complete_num = models.IntegerField()
    #头图
    img = models.ImageField(default='0.jpg')

    class Meta:
        db_table='path'

class Path_Stage(models.Model):
    stage = models.CharField(max_length=255)
    path_id = models.IntegerField()

    class Meta:
        db_table = 'path_stage'

class Course_Stage(models.Model):
    course_id = models.IntegerField()
    stage_id = models.IntegerField()

    class Meta:
        db_table = 'course_stage'

# 评论
class Course_Comment(models.Model):
    course_id = models.IntegerField()
    pid = models.IntegerField()
    uid = models.IntegerField()
    content = models.CharField(max_length=255)
    time = models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table='course_comment'


# 标签
class CourseTags(models.Model):
    course_tags = models.CharField(max_length=255)
    class Meta:
        db_table = 'course_tags'



    # 订单表
class Orders(models.Model):
    #订单号
    order_id = models.CharField(max_length=255)
    uid = models.IntegerField(null=True)
    #课程id
    course_id = models.IntegerField(null=True)
    price = models.IntegerField()
    #是否完成
    is_complete = models.IntegerField()
    creat_time = models.DateTimeField(auto_now_add=True)
    #订单类型(0 课程   1 会员)
    type = models.IntegerField()

    class Meta:
        db_table = 'orders'

class Chapter(models.Model):
    couse_id = models.IntegerField()
    chapter_name = models.CharField(max_length=255)
    video_content = models.CharField(max_length=255)
    section = models.CharField(max_length=255)
    class Meta:
        db_table= 'chapter'

class CourseType(models.Model):

    typename = models.CharField(max_length=255)

    class Meta:
        db_table='course_type'
